package com.wang.luntan.users.pojo;

import com.wang.luntan.common.pojo.BasePojo;
import lombok.Data;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;

@Data
public class AtUsers extends BasePojo<AtUsers> {
    private int id;
    private String email;
    private String password;
    private String souPass;
    private String nickName;
    private String trueName;
    private String qq;
    private String phone;
    private String weiXin;
    private Date birthday;
    private String address;
    private String photoPath;
    private byte sex;
    private byte status;
    private Date createTime;
    private Date updateTime;
    private Date lastLoginTime;
    private Date pubTime;

    private String statusStr;
    private String sexStr;
    /**
     * 用户的token
     */
    private String tokenStr;
    /**
     * 存储所有状态的容器
     */
    private Map<String, String> enumsMap = new TreeMap<String, String>();

    public Map<String, String> getEnumsMap() {
        // 根据状态值获取字符串描述
        AtUsersEnum[] usersEnums = AtUsersEnum.values();
        for (int i = 0; i < usersEnums.length; i++) {
            AtUsersEnum usersEnum = usersEnums[i];
            String key = usersEnum.toString();
            enumsMap.put(key + "-" + usersEnum.getStatus() + "", usersEnum.getName());
        }
        return enumsMap;
    }

    public String getStatusStr() {
        AtUsersEnum[] values = AtUsersEnum.values();
        for (int i = 0; i < values.length; i++) {
            AtUsersEnum usersEnumTemp = values[i];
            /*
             * toString:变量名 name:枚举的键, getstatus:枚举的值
             */
            if (usersEnumTemp.toString().startsWith("STATUS")) {
                if (usersEnumTemp.getStatus() == this.status) {
                    this.statusStr = usersEnumTemp.getName();
                }
            }
            // System.out.println(adminsEnumTemp.getName() + "=====>" +
            // adminsEnumTemp.getStatus() + "--->" + adminsEnumTemp);
        }
        return statusStr;
    }
}